aboutsummaryrefslogtreecommitdiffstats
path: root/src/routes/(app)/send/ark/[address]/+layout.server.ts
diff options
context:
space:
mode:
Diffstat (limited to 'src/routes/(app)/send/ark/[address]/+layout.server.ts')
-rw-r--r--src/routes/(app)/send/ark/[address]/+layout.server.ts15
1 files changed, 11 insertions, 4 deletions
diff --git a/src/routes/(app)/send/ark/[address]/+layout.server.ts b/src/routes/(app)/send/ark/[address]/+layout.server.ts
index 6381463a..18fb7aed 100644
--- a/src/routes/(app)/send/ark/[address]/+layout.server.ts
+++ b/src/routes/(app)/send/ark/[address]/+layout.server.ts
@@ -1,11 +1,18 @@
import { auth, get } from "$lib/utils";
import { redirect } from "@sveltejs/kit";
-export async function load({ cookies, params, parent }) {
+export async function load({ cookies, params, parent, url }) {
const { user } = await parent();
- const aid = cookies.get("aid") || user.id;
+ let aid = url.searchParams.get("aid") || cookies.get("aid") || user.id;
const { address, amount } = params;
- const { balance } = await get(`/account/${aid}`, auth(cookies));
+ let account = await get(`/account/${aid}`, auth(cookies));
+
+ // Fall back to custodial if cookie points to ark account
+ if (account.type === "ark" && aid !== user.id) {
+ aid = user.id;
+ account = await get(`/account/${aid}`, auth(cookies));
+ cookies.set("aid", aid, { path: "/", maxAge: 86400, httpOnly: false });
+ }
let invoice;
try {
@@ -21,5 +28,5 @@ export async function load({ cookies, params, parent }) {
if (recipient?.id !== user.id && recipient.id === invoice.aid) redirect(307, r);
}
- return { balance };
+ return { balance: account.balance };
}